import enum

class Ampel(enum.Flag):
    Rot = enum.auto()
    Gelb = enum.auto()
    Gruen = enum.auto()

kombinierter_zustand = Ampel.Rot | Ampel.Gelb
print(kombinierter_zustand)

# Ueberpruefung des Zustands mit &
print()
ist_rot = kombinierter_zustand & Ampel.Rot
print(ist_rot)
ist_gruen = kombinierter_zustand & Ampel.Gruen
print(ist_gruen)

# Interpretieren als Wahrheitswert
print()
ist_rot = bool(kombinierter_zustand & Ampel.Rot)
print(ist_rot)
ist_gruen = bool(kombinierter_zustand & Ampel.Gruen)
print(ist_gruen)
